﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using nERP.Model.Wms;
using nERP.Model;

using nERP.Model.Bas;
using nERP.Model.Po;


namespace nERP.ViewModel.Wms.BuyInWarehouseDetailVMs
{
    public partial class BuyInWarehouseDetailBuyInWarehouseDetailListVM : BasePagedListVM<BuyInWarehouseDetail, BuyInWarehouseDetailDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("BuyInWarehouseDetail", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("BuyInWarehouseDetail", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<BuyInWarehouseDetail>> InitGridHeader()
        {
            return new List<GridColumn<BuyInWarehouseDetail>>{
                
                this.MakeGridHeader(x => x.ID).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.ID"].Value),
                this.MakeGridHeader(x => x.CreateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.UpdateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.CreateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.UpdateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.UpdateBy"].Value),
                this.MakeGridHeader(x => x.TenantCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Tenant"].Value),
                this.MakeGridHeader(x => x.Seq).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.序号"].Value),
                this.MakeGridHeader(x => x.BuyInWarehouseDetailCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.入库明细单号"].Value),
                this.MakeGridHeader(x => x.WarehouseId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Warehouse>().GetSelectListItems(Wtm, x => x.WarehouseName, x => x.WarehouseCode,SortByName:true)).SetTitle(@Localizer["Page.仓库"].Value),
                this.MakeGridHeader(x => x.BuyId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Buy>().GetSelectListItems(Wtm, x => x.BuyCode, x => x.BuyCode,SortByName:true)).SetTitle(@Localizer["Page.采购订单"].Value),
                this.MakeGridHeader(x => x.BuyDetailId).SetEditType(EditTypeEnum.ComboBox,DC.Set<BuyDetail>().GetSelectListItems(Wtm, x => x.BuyDetailCode, x => x.BuyDetailCode,SortByName:true)).SetTitle(@Localizer["Page.采购明细"].Value),
                this.MakeGridHeader(x => x.GoodsId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Goods>().GetSelectListItems(Wtm, x => x.GoodsName, x => x.GoodsCode,SortByName:true)).SetTitle(@Localizer["Page.商品"].Value),
                this.MakeGridHeader(x => x.GoodsName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品名称"].Value),
                this.MakeGridHeader(x => x.GoodsSpec).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品规格"].Value),
                this.MakeGridHeader(x => x.GoodsUnit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.计量单位"].Value),
                this.MakeGridHeader(x => x.BuyInNumber).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.入库数量"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),
                this.MakeGridHeader(x => x.Status).SetEditType(EditTypeEnum.ComboBox,typeof(dStatusTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.状态"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<BuyInWarehouseDetail> GetSearchQuery()
        {
                
            var id = (string)Searcher.BuyInWarehouseId.ConvertValue(typeof(string));
            if (id == null)
                return new List<BuyInWarehouseDetail>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<BuyInWarehouseDetail>()
                .Where(x => id == x.BuyInWarehouseId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class BuyInWarehouseDetailDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._BuyInWarehouseDetail._BuyInWarehouse")]
        public string BuyInWarehouseId { get; set; }
    }

}

